/**
 * This class contains unit tests for validating the behavior of Apex classes
 * and triggers.
 *
 * Unit tests are class methods that verify whether a particular piece
 * of code is working properly. Unit test methods take no arguments,
 * commit no data to the database, and are flagged with the testMethod
 * keyword in the method definition.
 *
 * All test methods in an organization are executed whenever Apex code is deployed
 * to a production organization to confirm correctness, ensure code
 * coverage, and prevent regressions. All Apex classes are
 * required to have at least 75% code coverage in order to be deployed
 * to a production organization. In addition, all triggers must have some code coverage.
 * 
 * The @isTest class annotation indicates this class only contains test
 * methods. Classes defined with the @isTest annotation do not count against
 * the organization size limit for all Apex scripts.
 *
 * See the Apex Language Reference for more information about Testing and Code Coverage.
 */
@isTest
private class Test_APTI_Trigger_class {

    static testMethod void myUnitTest() {
        Test.startTest();
        //Testing AptiIntegration_OnLead Trigger
        Lead l=new Lead();
	    l.email='john@john.com';
	    l.firstname='John';
	    l.HasOptedOutOfEmail=false;
	    l.lastname='Coppedge';
	    l.RecordTypeId=Schema.sObjectType.Lead.getRecordTypeInfosByName().get('West - Prospective Student').getRecordTypeId();
	    l.Personal_Email__c='john@john.com';
	    l.status='Contacted';
	    l.phone='(801) 555-5556';
	    l.APTI_ID__c = '127541386';
	    l.Push_Lead__c = false;
	    l.Hot_Transfer__c = false;	    
	    DateTime birthDate= DateTime.now(); //DateTime variable
	    String birthDate_Formatted_Date = birthDate.format('yyyy-MM-dd');
	    l.Birth_Date__c=date.valueof(birthDate_Formatted_Date);
	    l.Work_Phone__c='(801) 555-5556';
	    l.Country = 'Mexico';	    
	    insert l;
	    
	    l.Push_Lead__c = true;
	    update l;
	    
	    l.Hot_Transfer__c = true;
	    update l;
	    
	    l.Status = 'Declined';
	    l.Status_Detail__c = 'Tuition Too Expensive';
	    update l;
	    
	    //Testing AptiIntegration_OnOpportunity Trigger
	    Account A = new Account();
        A.LastName = 'Test';
        A.FirstName = 'Unit';
        A.Account_Assigned_Date__c = Date.valueOf('2012-02-27');
        A.Age_Rage__pc = '24 to 39';
        A.Birth_Date__c = Date.valueOf('1982-01-03');
        A.Delegation_or_Municipality__c = 'Benito Juarez';
        A.Gender__pc = 'Male';
        A.Other_City__c = 'México DF';
        A.Personal_Email__pc   = 'testuser123@prueba.com';
        A.PersonEmail = 'testuser123@prueba.com';
        A.PersonMobilePhone = '5598741230';
        A.Phone = '5598741230';
        A.Preferred_Email__pc  = 'Personal Email';
        A.Preferred_Phone__pc = 'Mobile Phone';
        A.RecordTypeId = Schema.sObjectType.Account.getRecordTypeInfosByName().get('West - Student Account').getRecordTypeId();
        A.Status__c = 'Prospect';
        insert A;
        
        Opportunity oppty = new Opportunity();
        oppty.Name= 'Unit Test';
        oppty.AccountId = A.Id;
        oppty.RecordTypeId = Schema.sObjectType.Opportunity.getRecordTypeInfosByName().get('West - Student Application').getRecordTypeId();
        oppty.Registrant_Type__c = 'High School - Local';
        oppty.StageName = 'Application Started';
        oppty.Payment_plan__c = '3';
        oppty.APTI_ID__c = '127541162';
        oppty.CloseDate = Date.valueOf('2012-04-01');
        insert oppty;
       /* 
        oppty.StageName = 'Declined';
        oppty.Status_Detail__c = 'Did Not Request Information';
        update oppty;
        
        oppty.StageName = 'Registered';
        oppty.Status_Detail__c = 'Pending Start';
        update oppty;*/
	    Test.stopTest();
    }
}